home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / recov / recov.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  14.8 KB  |  375 lines

  1. /*
  2.  * recov.h --
  3.  *
  4.  *    External definitions needed by users of the Recovery system.
  5.  *    This module maintains up/down state about other hosts, provides
  6.  *    a call-back mechanism for other modules, and some state bits
  7.  *    that can also be set by other modules.
  8.  *
  9.  * Copyright (C) 1985 Regents of the University of California
  10.  * All rights reserved.
  11.  *
  12.  *
  13.  * $Header: /cdrom/src/kernel/Cvsroot/kernel/recov/recov.h,v 9.23 92/12/13 18:20:09 mgbaker Exp $ SPRITE (Berkeley)
  14.  */
  15.  
  16. #ifndef _RECOV
  17. #define _RECOV
  18.  
  19. #ifdef KERNEL
  20. #include <trace.h>
  21. #include <proc.h>
  22. #else
  23. #include <kernel/trace.h>
  24. #include <kernel/proc.h>
  25. #endif
  26. #include <recovBox.h>
  27. #include <hostd.h>
  28.  
  29. /*
  30.  * External view of the state kept about each host.
  31.  */
  32. typedef struct Recov_State {
  33.     int spriteID;        /* Host ID of the peer */
  34.     unsigned int bootID;    /* Boot timestamp from RPC header */
  35.     int state;            /* Recovery state, defined below */
  36.     int clientState;        /* Client bits */
  37.     Time time;            /* Time of last message */
  38. } Recov_State;
  39. /*
  40.  * recov_PrintLevel defines how noisey we are about other hosts.
  41.  *    Values for the print level should be defined in increasing order.
  42.  */
  43. #define RECOV_PRINT_NONE    0
  44. #define RECOV_PRINT_REBOOT    1
  45. #define RECOV_PRINT_IF_UP    2
  46. #define RECOV_PRINT_CRASH    2
  47. #define RECOV_PRINT_ALL        10
  48.  
  49. extern int recov_PrintLevel;
  50.  
  51. /*
  52.  * Host state used by the recov module and accessible via the
  53.  * Recov_{G,S}etHostState calls:
  54.  *    RECOV_STATE_UNKNOWN    Initial state.
  55.  *    RECOV_HOST_ALIVE    Set when we receive a message from the host
  56.  *    RECOV_HOST_DEAD        Set when crash callbacks have been started.
  57.  *    RECOV_HOST_BOOTING    Set in the limbo period when a host is booting
  58.  *                and talking to the world, but isn't ready
  59.  *                for full recovery actions yet.
  60.  *
  61.  *    RECOV_CRASH_CALLBACKS    Set during the crash call-backs, this is used
  62.  *                to block RPC server processes until the
  63.  *                crash recovery actions have completed.
  64.  *    RECOV_WANT_RECOVERY    Set if another module wants a callback at reboot
  65.  *    RECOV_PINGING_HOST    Set for hosts we ping to see when it reboots.
  66.  *    RECOV_REBOOT_CALLBACKS    Set while reboot callbacks are pending.
  67.  *    RECOV_FAST_BOOT        Set if the server went through a fast boot.
  68.  *    RECOV_SERVER_DRIVEN    Set if the server is driving recovery.
  69.  *    RECOV_FAILURE        Set if a communication failure occurs during
  70.  *                the reboot callbacks.  This triggers another
  71.  *                invokation of the reboot callbacks so that
  72.  *                a client can't miss out on recovery.
  73.  *
  74.  *    RECOV_CRASH        artificial state to trace RecovCrashCallBacks
  75.  *    RECOV_REBOOT        artificial state to trace RecovRebootCallBacks
  76.  */
  77. #define RECOV_STATE_UNKNOWN    0x0
  78. #define RECOV_HOST_ALIVE    0x1
  79. /* Space here now. */
  80. #define RECOV_HOST_DEAD        0x4
  81.  
  82. #define RECOV_HOST_BOOTING    0x10
  83. #define RECOV_CRASH        0x20
  84. #define RECOV_REBOOT        0x40
  85. #define RECOV_FAILURE        0x80
  86.  
  87. #define RECOV_CRASH_CALLBACKS    0x0100
  88. #define RECOV_WANT_RECOVERY    0x0200
  89. #define RECOV_PINGING_HOST    0x0400
  90. #define RECOV_REBOOT_CALLBACKS    0x0800
  91.  
  92. #define    RECOV_FAST_BOOT        0x1000
  93. #define    RECOV_SERVER_DRIVEN    0x2000
  94.  
  95. /*
  96.  * If dying_state is not defined then crash callbacks are made
  97.  * immidiately after a timeout.  Otherwise the host lingers in
  98.  * the RECOV_HOST_DYING state for recov_CrashDelay seconds.
  99.  */
  100. #undef dying_state
  101.  
  102. /*
  103.  * Host state flags for use by Recov clients.  These flags are set
  104.  * by users of the Recov module to define/get host states beyond
  105.  * the simple up/down state maintained by the Recov system.
  106.  *    CLT_RECOV_IN_PROGRESS    The client needs to go through full
  107.  *                recovery with the server.  This is set when
  108.  *                the server gets a reopen from the client,
  109.  *                and reset after the
  110.  *                client tells us it's done re-opening files.
  111.  *                The flag is used on the server to tell us to
  112.  *                block opens from this client while it is
  113.  *                going through recovery.
  114.  *    SRV_RECOV_IN_PROGRESS    This is set on a client while it is reopening
  115.  *                files in order to ensure only one set of
  116.  *                reopens is in process.
  117.  *    SRV_RECOV_FAILED    Recovery with the server failed.  This is
  118.  *                used to catch a race between the end of
  119.  *                a failed recovery and re-establishing contact
  120.  *                with the server.  If the server "comes back"
  121.  *                before a failed recovery clears the
  122.  *                SRV_RECOV_IN_PROGRESS bit, then a reboot
  123.  *                callback could get lost.  This bit is used
  124.  *                to detect this.
  125.  *    CLT_OLD_RECOV        This client is running an old kernel and
  126.  *                returned INVALID_RPC to server trying to get
  127.  *                it to do server-driven recovery.
  128.  *    CLT_DOING_SRV_RECOV    Client is currently going through server-driven
  129.  *                recovery.
  130.  *    SRV__DRIVEN_IN_PROGRESS    Set on client if server has contacted client
  131.  *                for server-driven recovery.
  132.  */
  133. #define CLT_RECOV_IN_PROGRESS    0x01
  134. #define SRV_RECOV_IN_PROGRESS    0x02
  135. #define SRV_RECOV_FAILED    0x04
  136. #define CLT_OLD_RECOV        0x08
  137. #define CLT_DOING_SRV_RECOV    0x10
  138. #define    SRV_DRIVEN_IN_PROGRESS    0x20
  139.  
  140. /*
  141.  * Whether or not to use absolute intervals for pinging servers.  The default
  142.  * is to use them in order to avoid synchronizing clients due to server
  143.  * reboots.
  144.  */
  145. extern    Boolean    recov_AbsoluteIntervals;
  146.  
  147. /*
  148.  * Trace types for use with Recov_HostTrace.  Compatible with recov.h bits.
  149.  *    RECOV_TRACE_FS_STALE    A stale handle was returned from a file server
  150.  */
  151. #define RECOV_TRACE_FS_STALE    0x1000
  152.  
  153. /*
  154.  * A trace is kept for debugging/understanding the host state transisions.
  155.  */
  156. typedef struct RecovTraceRecord {
  157.     int        spriteID;        /* Host ID whose state changed */
  158.     int        state;            /* Their new state */
  159. } RecovTraceRecord;
  160.  
  161. /*
  162.  * Tracing events, these describe the trace record.
  163.  *
  164.  *    RECOV_CUZ_WAIT        Wait in Recov_WaitForHost
  165.  *    RECOV_CUZ_WAKEUP    Wakeup in Recov_WaitForHost
  166.  *    RECOV_CUZ_INIT        First time we were interested in the host
  167.  *    RECOV_CUZ_REBOOT    We detected a reboot
  168.  *    RECOV_CUZ_CRASH        We detected a crash
  169.  *    RECOV_CUZ_DONE        Recovery actions completed
  170.  *    RECOV_CUZ_PING_CHK    We are pinging the host to check it out
  171.  *    RECOV_CUZ_PING_ASK    We are pinging the host because we were asked
  172.  *    RECOV_CUZ_CRASH_UNDETECTED    Crash wasn't detected until reboot
  173.  *    RECOV_CUZ_SCHED_CALLBACK    Called Proc_CallFunc to schedule
  174.  *                    reboot callbacks.
  175.  *    RECOV_CUZ_DONE_CALLBACKS    Called CallBacksDone. 
  176.  *    RECOV_CUZ_FAILURE    RECOV_FAILURE was detected in CallBacksDone.
  177.  *    RECOV_CUZ_WAS_BOOTING    Got alive packet when in booting state.
  178.  *    RECOV_CUZ_NOW_BOOTING    Got booting packet when in dead state.
  179.  *    RECOV_CUZ_WAS_DEAD    Got alive packet when in dead state.
  180.  *    RECOV_CUZ_DOING_CALLBACKS    In RecovRebootCallBacks. 
  181.  *    RECOV_CUZ_START        We're starting up, so maybe unknown state.
  182.  */
  183. #define RECOV_CUZ_WAIT        0x1
  184. #define RECOV_CUZ_WAKEUP    0x2
  185. #define RECOV_CUZ_INIT        0x4
  186. #define RECOV_CUZ_REBOOT    0x8
  187. #define RECOV_CUZ_CRASH        0x10
  188. #define RECOV_CUZ_DONE        0x20
  189. #define RECOV_CUZ_PING_CHK    0x40
  190. #define RECOV_CUZ_PING_ASK    0x80
  191. #define RECOV_CUZ_CRASH_UNDETECTED    0x100
  192. #define RECOV_CUZ_SCHED_CALLBACK    0x200
  193. #define RECOV_CUZ_DONE_CALLBACKS    0x400
  194. #define RECOV_CUZ_FAILURE    0x800
  195. /* 0x1000 taken by stale handle thing, above. */
  196. #define RECOV_CUZ_WAS_BOOTING    0x2000
  197. #define RECOV_CUZ_NOW_BOOTING    0x4000
  198. #define RECOV_CUZ_WAS_DEAD    0x8000
  199. #define RECOV_CUZ_DOING_CALLBACKS    0x10000
  200. #define RECOV_CUZ_START        0x20000
  201.  
  202. #ifndef CLEAN
  203.  
  204. #define RECOV_TRACE(zspriteID, zstate, event) \
  205.     if (recovTracing) {\
  206.     RecovTraceRecord rec;\
  207.     rec.spriteID = zspriteID;\
  208.     rec.state = zstate;\
  209.     Trace_Insert(recovTraceHdrPtr, event, (ClientData)&rec);\
  210.     }
  211. #else
  212.  
  213. #define RECOV_TRACE(zspriteID, zstate, event)
  214.  
  215. #endif /* not CLEAN */
  216.  
  217. /*
  218.  * More parameters for controlling recovery.  The first of these
  219.  * (0 to 99) are for the use of the recovery box and are defined in
  220.  * /usr/include/recovBox.h.
  221.  */
  222. #define    RECOV_BULK_REOPEN    100    /* Do bulk reopen rpcs. */
  223. #define    RECOV_SINGLE_REOPEN    101    /* Do normal reopen rpcs. */
  224. #define    RECOV_IGNORE_CLEAN    102    /* Don't reopen files that have only
  225.                      * clean blocks in the cache. */
  226. #define    RECOV_REOPEN_CLEAN    103    /* Do reopen files that have only
  227.                      * clean blocks in the cache. */
  228. #define    RECOV_SKIP_CLEAN    104    /* Skip the reopen of files that have
  229.                      * only clean blocks in the cache.
  230.                      * But don't invalidate them as is
  231.                      * done for IGNORE_CLEAN. */
  232. #define RECOV_DO_SERVER_DRIVEN    105    /* Turn on server-driven recovery
  233.                      * acceptance for clients.
  234.                      */
  235. #define RECOV_NO_SERVER_DRIVEN    106    /* Turn off server-driven recovery
  236.                      * acceptance for clients.
  237.                      */
  238.  
  239. extern Trace_Header *recovTraceHdrPtr;
  240. extern Boolean recovTracing;
  241. /*
  242.  * Statistics about the recovery module.
  243.  */
  244. typedef struct Recov_Stats {
  245.     int packets;    /* Number of packets examined */
  246.     int    pings;        /* Number of pings made to check on other hosts */
  247.     int pingsSuppressed;/* Number of pings that were suppressed due to
  248.              * recent message traffic */
  249.     int timeouts;    /* The number of timeout's detected */
  250.     int crashes;    /* The number of times crash call-backs were called */
  251.     int nonCrashes;    /* The number of times crash call-backs were avoided */
  252.     int reboots;    /* The number of times reboot call-backs were called */
  253.     int numHostsPinged;    /* The number of hosts being pinged */
  254. } Recov_Stats;
  255.  
  256. extern Recov_Stats recov_Stats;
  257. extern    Boolean    recov_RestartDebug;
  258.  
  259. /*
  260.  * TRUE if we're using transparent server recovery.
  261.  */
  262. extern    Boolean        recov_Transparent;
  263. /*
  264.  * TRUE if we want a client to ignore the fact that a server can do transparent
  265.  * recovery.  If the client ignores this, this means it sends reopen requests
  266.  * even though it doesn't have to.  (In this case, the server will check
  267.  * the client's info against what it has stored in its recovery box.)
  268.  */
  269. extern    Boolean        recov_ClientIgnoreTransparent;
  270.  
  271. /*
  272.  * TRUE if client is ignoring server-driven recovery.  It will repsond
  273.  * instead with "invalid rpc."
  274.  */
  275. extern    Boolean        recov_ClientIgnoreServerDriven;
  276.  
  277. /*
  278.  * TRUE if we're avoiding downloading text and initialized data.  (Should
  279.  * be true usually.)
  280.  */
  281. extern    Boolean        recov_DoInitDataCopy;
  282.  
  283. /*
  284.  * Do batching of reopen rpc's.
  285.  */
  286. extern    Boolean        recov_BulkHandles;
  287.  
  288. /*
  289.  * Don't bother to reopen files that have only clean blocks in the cache.
  290.  */
  291. extern    Boolean        recov_IgnoreCleanFiles;
  292.  
  293. /*
  294.  * Skip reopening this file.  It may have clean blocks in the cache, but
  295.  * it has no current streams.  The server will be contacted by reguar means
  296.  * the next time somebody opens the file.
  297.  */
  298. extern    Boolean        recov_SkipCleanFiles;
  299. /*
  300.  * Server is driving recovery, rather than allowing clients to initiate it.
  301.  */
  302. extern    Boolean    recov_ServerDriven;
  303.  
  304. /*
  305.  * We're blocking rpc's that aren't related to recovery.
  306.  */
  307. extern    Boolean    recov_BlockingRpcs;
  308.  
  309. /*
  310.  * A printf for during recovery.
  311.  */
  312. #define qprintf if (recov_BlockingRpcs) printf
  313.  
  314. extern void     Recov_Init _ARGS_((void));
  315. extern void     Recov_CrashRegister _ARGS_((void (*crashCallBackProc)(), ClientData crashData));
  316. extern void     Recov_RebootRegister _ARGS_((int spriteID, void (*rebootCallBackProc)(), ClientData rebootData));
  317. extern void     Recov_RebootUnRegister _ARGS_((int spriteID, void (*rebootCallBackProc)(), ClientData rebootData));
  318. extern void     Recov_HostAlive _ARGS_((int spriteID, unsigned int bootID, Boolean asyncRecovery, Boolean rpcNotActive, unsigned int recovType));
  319. extern void     Recov_HostDead _ARGS_((int spriteID));
  320. extern int     Recov_GetHostState _ARGS_((int spriteID));
  321. extern int     Recov_GetHostOldState _ARGS_((int spriteID));
  322. extern void     Recov_SetHostOldState _ARGS_((int spriteID, int state));
  323. extern Boolean     Recov_GetHostInfo _ARGS_((int spriteID, Recov_State *recovStatePtr));
  324. extern ReturnStatus     Recov_IsHostDown _ARGS_((int spriteID));
  325. extern void     Recov_HostTrace _ARGS_((int spriteID, int event));
  326. extern int     Recov_GetClientState _ARGS_((int spriteID));
  327. extern int     Recov_SetClientState _ARGS_((int spriteID, int stateBits));
  328. extern void     Recov_ClearClientState _ARGS_((int spriteID, int stateBits));
  329. extern void     Recov_AddHandleCountToClientState _ARGS_((int type, int clientID, ReturnStatus status));
  330. extern void     RecovRebootCallBacks _ARGS_((ClientData data, Proc_CallInfo *callInfoPtr));
  331. extern ReturnStatus     Recov_DumpClientRecovInfo _ARGS_((int length, Address resultPtr, int *lengthNeededPtr));
  332. extern ReturnStatus     Recov_GetStats _ARGS_((int size, Address userAddr));
  333. extern ReturnStatus     Recov_DumpState _ARGS_((int size, Address userAddr));
  334. extern void         Recov_ChangePrintLevel _ARGS_((int newLevel));
  335. extern void         RecovPingInit _ARGS_((void));
  336. extern void         RecovPrintPingList _ARGS_((void));
  337. extern void         Recov_PrintTrace _ARGS_((ClientData numRecs));
  338. extern void         Recov_PrintState _ARGS_((void));
  339. extern int         Recov_PrintTraceRecord _ARGS_((ClientData clientData, int event, Boolean printHeaderFlag));
  340. extern void         Recov_Proc _ARGS_((void));
  341. extern void         RecovAddHostToPing _ARGS_((int spriteID));
  342. extern int         RecovCheckHost _ARGS_((int spriteID));
  343. extern int         RecovGetLastHostState _ARGS_((int spriteID));
  344. extern Boolean        Recov_InitRecovBox _ARGS_((void));
  345. extern ReturnStatus    Recov_InitType _ARGS_((int objectSize, int maxNumObjects, int applicationTypeID, int *objectTypePtr, unsigned short (*Checksum)()));
  346. extern ReturnStatus    Recov_InsertObject _ARGS_((int typeID, ClientData objectPtr, int applicationObjectNum, Recov_ObjectID *objectIDPtr));
  347. extern ReturnStatus    Recov_InsertObjects _ARGS_((int typeID, int numObjs, char *obuffer, int *objNumBuffer, Recov_ObjectID *objIDBuffer));
  348. extern ReturnStatus    Recov_DeleteObject _ARGS_((Recov_ObjectID objectID));
  349. extern ReturnStatus    Recov_UpdateObject _ARGS_((ClientData objectPtr, Recov_ObjectID objectID));
  350. extern ReturnStatus    Recov_ReturnObject _ARGS_((ClientData objectPtr, Recov_ObjectID objectID, Boolean checksum));
  351. extern ReturnStatus    Recov_ReturnObjects _ARGS_((int typeID, int *olengthPtr, char *obuffer, int *ilengthPtr, char *ibuffer, int *alengthPtr, char *abuffer));
  352. extern ReturnStatus    Recov_ReturnContents _ARGS_((int *lengthPtr, char *buffer));
  353. extern int        Recov_MaxNumObjects _ARGS_((int objectSize, Boolean restart));
  354. extern    void        Recov_PrintSpace _ARGS_((int objectSize));
  355. extern    void        Recov_ToggleChecksum _ARGS_((int typeID));
  356. extern    int        Recov_NumObjects _ARGS_((int typeID));
  357. extern    int        Recov_GetObjectSize _ARGS_((int typeID));
  358. extern ReturnStatus    Recov_MapType _ARGS_((int applicationTypeID, int *typeIDPtr));
  359. extern ReturnStatus    Recov_MapObjectNum _ARGS_((int typeID, int applicationObjectNum, int *objectNumPtr));
  360. extern unsigned short    Recov_Checksum _ARGS_((int len, Address bufPtr));
  361. extern    ReturnStatus    Recov_Cmd _ARGS_((int option, Address argPtr));
  362. extern    void        Recov_InitServerDriven _ARGS_((void));
  363. extern    void        Recov_StartServerDrivenRecovery _ARGS_((int serverID));
  364. extern    void         Recov_WaitForServerDriven _ARGS_((int serverID));
  365. extern    void        Recov_MarkOldClient _ARGS_((int clientID));
  366. extern    void        Recov_ServerStartingRecovery _ARGS_((void));
  367. extern    void        Recov_ServerFinishedRecovery _ARGS_((void));
  368. extern    Boolean        Recov_HoldForRecovery _ARGS_((int clientID, int command));
  369. extern    void        Recov_StopServerDriven _ARGS_((void));
  370. extern    int        Recov_GetCurrentHostStates _ARGS_((Dev_ClientInfo *infoBuffer, int bufEntries));
  371. extern    void        Recov_MarkDoingServerRecovery _ARGS_((int clientID));
  372. extern    void        Recov_UnmarkDoingServerRecovery _ARGS_((int clientID));
  373. #endif /* _RECOV */
  374.  
  375.